/*
 * This file is part of aion-unique <aion-unique.org>.
 *
 *  aion-unique is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  aion-unique is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with aion-unique.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionemu.gameserver.model.gameobjects.stats;

import com.aionemu.gameserver.model.gameobjects.instance.Summon;
import com.aionemu.gameserver.model.templates.stats.SummonStatsTemplate;

/**
 * @author ATracer
 *
 */
public class SummonGameStats extends CreatureGameStats<Summon>
{

	private SummonStatsTemplate statsTemplate;
	/**
	 * 
	 * @param owner
	 * @param statsTemplate
	 */
	public SummonGameStats(Summon owner, SummonStatsTemplate statsTemplate)
	{
		super(owner);
		this.statsTemplate = statsTemplate;
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getStat(com.aionemu.gameserver.model.gameobjects.stats.StatEnum, float)
	 */
	@Override
	public Stat getStat(StatEnum statEnum, float base)
	{
		Stat stat =  super.getStat(statEnum, base);
		if (owner.getMaster() == null)
			return stat;
		switch(statEnum)
		{
			case MAXHP:
			case PHYSICAL_DEFENSE:
			case EVASION:
			case BOOST_MAGICAL_SKILL:
			case MAGICAL_ACCURACY:
			case MAGICAL_RESIST:
				return owner.getMaster().getGameStats().getSummonStatBoost(statEnum, stat);
			case PHYSICAL_ACCURACY:
				owner.getMaster().getGameStats().getSummonStatBoost(StatEnum.PHYSICAL_ACCURACY_MAIN_HAND, stat);
				return owner.getMaster().getGameStats().getSummonStatBoost(statEnum, stat);
			case PHYSICAL_CRITICAL:
				owner.getMaster().getGameStats().getSummonStatBoost(StatEnum.PHYSICAL_CRITICAL_MAIN_HAND, stat);
				return owner.getMaster().getGameStats().getSummonStatBoost(statEnum, stat);
			case PHYSICAL_ATTACK:
				owner.getMaster().getGameStats().getSummonStatBoost(StatEnum.PHYSICAL_ATTACK_MAIN_HAND, stat);
				return owner.getMaster().getGameStats().getSummonStatBoost(statEnum, stat);
				
		}
		
		return stat;
	}
	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMovementSpeed()
	 */
	@Override
	public Stat getMovementSpeed()
	{
		return getStat(StatEnum.SPEED, Math.round(statsTemplate.getRunSpeed()*1000));
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMaxHP()
	 */
	@Override
	public Stat getMaxHP()
	{
		return getStat(StatEnum.MAXHP, statsTemplate.getMaxHp());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMaxMP()
	 */
	@Override
	public Stat getMaxMP()
	{
		return getStat(StatEnum.MAXHP, statsTemplate.getMaxMp());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getAttackSpeed()
	 */
	@Override
	public Stat getAttackSpeed()
	{
		return getStat(StatEnum.ATTACK_SPEED, owner.getObjectTemplate().getCreatureStatData().getAttackDelay());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getAttackRange()
	 */
	@Override
	public Stat getAttackRange()
	{
		return getStat(StatEnum.ATTACK_RANGE, Math.round(owner.getObjectTemplate().getCreatureStatData().getAttackRange()*1000));
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getPDef()
	 */
	@Override
	public Stat getPDef()
	{
		return getStat(StatEnum.PHYSICAL_DEFENSE, statsTemplate.getPdefense());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMagicalResist()
	 */
	@Override
	public Stat getMagicalResist()
	{
		return getStat(StatEnum.MAGICAL_RESIST, statsTemplate.getMresist());
	}
	
	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getPower()
	 */
	@Override
	public Stat getPower()
	{
		return getStat(StatEnum.POWER, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getHealth()
	 */
	@Override
	public Stat getHealth()
	{
		return getStat(StatEnum.HEALTH, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getAccuracy()
	 */
	@Override
	public Stat getAccuracy()
	{
		return getStat(StatEnum.ACCURACY, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getAgility()
	 */
	@Override
	public Stat getAgility()
	{
		return getStat(StatEnum.AGILITY, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getKnowledge()
	 */
	@Override
	public Stat getKnowledge()
	{
		return getStat(StatEnum.KNOWLEDGE, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getWill()
	 */
	@Override
	public Stat getWill()
	{
		return getStat(StatEnum.WILL, 100);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMainHandPAttack()
	 */
	@Override
	public Stat getMainHandPAttack()
	{
		return getStat(StatEnum.PHYSICAL_ATTACK, statsTemplate.getMainHandAttack());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMainHandPCritical()
	 */
	@Override
	public Stat getMainHandPCritical()
	{
		return getStat(StatEnum.PHYSICAL_CRITICAL, statsTemplate.getMainHandCritRate());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getPAccuracy()
	 */
	@Override
	public Stat getMainHandPAccuracy()
	{
		return getStat(StatEnum.PHYSICAL_ACCURACY, statsTemplate.getMainHandAccuracy());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMagicalBoost()
	 */
	@Override
	public Stat getMagicalBoost()
	{
		return getStat(StatEnum.BOOST_MAGICAL_SKILL, statsTemplate.getMainHandAccuracy());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMagicalAccuracy()
	 */
	@Override
	public Stat getMagicalAccuracy()
	{
		return getStat(StatEnum.MAGICAL_ACCURACY, statsTemplate.getMagicAccuracy());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getMagicalCritical()
	 */
	@Override
	public Stat getMagicalCritical()
	{
		return getStat(StatEnum.MAGICAL_CRITICAL, 50);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getEvasion()
	 */
	@Override
	public Stat getEvasion()
	{
		return getStat(StatEnum.EVASION, statsTemplate.getEvasion());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getParry()
	 */
	@Override
	public Stat getParry()
	{
		return getStat(StatEnum.PARRY, statsTemplate.getParry());
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.stats.CreatureGameStats#getBlock()
	 */
	@Override
	public Stat getBlock()
	{
		return getStat(StatEnum.BLOCK, statsTemplate.getBlock());
	}
}
